(function(){
	
    $.fn.loginForm = function(){
        $(this).submit(function(){
            // Get url of form
            var url = $(this).attr('action');
            url += '?act=login';
			
            var uname = $('> #uname', this).val();
            var upass = $('> #upass', this).val();
            var bLogin = $('> #btnLogin', this).val();
			
            // Post data to url
            $.post(
                url,
                {
                    'uname': uname,
                    'upass':upass,
                    'act':'login'
                },
                function (data){
                    var rs = data;
                    $('.contact').empty().append(rs);
                },
                'html'
                );
			
            return false;
        });
    }
	
    $.fn.logoutForm = function(){
        $('> .btnLogout',this).click(function(){
			
            // Get url of form

            var url = $(this).parent().attr('action') +'?act=logout';
            //var url = '';
			
            var bLogin = 'btnLogout';
			
			
            // Post data to url
            $.post(
                url,
                {
                    'btnLogout':bLogin
                },
                function (data){
                     var rs = data;
                    $('.contact').empty().append(rs);
                },
                'html'
                );
            return false;
        });
    }

     $.fn.cbOnChange = function(){
        var url = $('#url', this).attr('value');
        $('.cb_Category_02', this).change(function(){
            var data = $(this).attr('value');

            // Post data to url
            $.post(
                url,
                {
                    'cate':data
                },
                function (data){
                    var rs = $(data).html();
                    $('.body_right').find('.items_content').empty().append(rs);
                },
                'html'
                );
        });
     }

    $.fn.saveItem = function (){
        $(this).submit(function(){

            // get url from action
            var url = $(this).attr('action');

            // Post data to url
            $.post(
                url,
                $(this).serialize(),
                function (data){
                    var rs = data;
                    $('.messages').empty().append(rs);
                },
                'html'
            );

            return false;
        });
    }

    $.fn.registerUsers = function (){
        $(this).submit(function(){

            // get url from action
            var url = $(this).attr('action');

            // Post data to url
            $.post(
                url,
                $(this).serialize(),
                function (data){
                    var rs = data;
                    $('.messages').empty().append(rs);
                },
                'html'
            );

            return false;
        });
    }
	
})(jQuery);
